<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SyntaxError</title>
    <style>
        * {
            font-size: 28px;
        }
    </style>
</head>

<body>

    <button type="button" id="btnEx">不能捕获的</button>

    <script>


        window.onerror = function (message, source, lineno, colno, error) {
            var string = msg.toLowerCase();
            var substring = "script error";
            if (string.indexOf(substring) > -1) {
                alert('Script Error: See Browser Console for Detail');
            } else {
                var message = [
                    'Message: ' + msg,
                    'URL: ' + url,
                    'Line: ' + lineNo,
                    'Column: ' + columnNo,
                    'Error object: ' + JSON.stringify(error)
                ].join(' - ');

                console.log(message);
            }
        }

        window.addEventListener("error", function(){
            console.log('Script Error: See Browser Console for')
        }, true);

        btnEx.onclick = function () {
            try {
                var hhhh bbbb;

            } catch (e) {
                console.log('e.message:', e.message);
            }
        }
    </script>
</body>